<?php

namespace App\Http\Requests\Admin\Tenant;

use App\Models\Tenant;
use Illuminate\Foundation\Http\FormRequest;

class StoreTenantRequest extends FormRequest
{
    public function authorize(): bool
    {
        return $this->user('admin') !== null;
    }

    public function rules(): array
    {
        return [
            'name' => 'required|string|max:255',
            'company_name' => 'nullable|string|max:200',
            'tax_registration_number' => 'nullable|string|max:50',
            'address' => 'nullable|string|max:500',
            'bank_name' => 'nullable|string|max:200',
            'bank_account' => 'nullable|string|max:100',
            'contact_phone' => 'required|string|max:20',
            'contact_email' => 'required|email|max:100',
            'service_fee_rate' => 'required|numeric|min:0|max:1',
            'tenant_type' => 'sometimes|in:' . implode(',', [
                Tenant::TYPE_ENTERPRISE,
            ]),
        ];
    }
}
